package com.example.tests;

import static org.junit.Assert.*;

import org.junit.Test;
import com.example.pages.InternalPage;
import com.example.pages.LoginPage;
import com.example.pages.UserManagementPage;

public class CreateNewUser extends TestBase {

	public LoginPage loginPage;
	public InternalPage somePage;

	@Test
	public void newUser() {
		UserManagementPage userManagementPage = goToMainPage()
				.loginWithValidCredentials("admin", "admin")
				.gotomenuUserManagement();

		SortedListOf<User> oldUserList = userManagementPage.getUsers();

		User user = new User().withName("aaauser1")
				.withEmail("aauser1@mail.com").withPassword("test");
		if (oldUserList.contains(user)) {
			userManagementPage.deleteUser(user);
			oldUserList = userManagementPage.getUsers();
		}
		userManagementPage.createNewUser(user);

		SortedListOf<User> newUserList = userManagementPage.getUsers();

		assertEquals(newUserList, oldUserList.withAdded(user));
	}

}
